//------------------------------------------------------------------------------ 
//      Copyright (c) 2004-2009, Be Nanashi-San 
// 
//      Permission is hereby granted, free of charge, to any person obtaining a 
//      copy of this software and associated documentation files (the "Software"), 
//      to deal in the Software without restriction, including without limitation 
//      the rights to use, copy, modify, merge, publish, distribute, sublicense, 
//      and/or sell copies of the Software, and to permit persons to whom the 
//      Software is furnished to do so, subject to the following conditions: 
// 
//      The above copyright notice and this permission notice shall be included in 
//      all copies or substantial portions of the Software. 
// 
//      THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
//      IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
//      FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
//      AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
//      LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
//      FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
//      DEALINGS IN THE SOFTWARE. 
// 
//      File Name:	ThreadListView.h
//      Author: 	Be Nanashi-San 
//      Description:	 
//------------------------------------------------------------------------------

#ifndef THREADLISTVIEW_H_INCLUDED
#define THREADLISTVIEW_H_INCLUDED

// 2006.12.12 compile for Haiku
#include "ColumnListView/ColumnListView.h"
#include "ThreadRunner.h"
#include "arrows.h"

class ThreadListView : public BColumnListView
{
friend BRow* makeThreadRow(ThreadListView *fView, char *title, char *datname, int resnum, int threadposion);
public:
	ThreadListView();
	virtual ~ThreadListView();
	void MessageReceived (BMessage * msg);
	void AttachedToWindow();
	bool CurrentQuery (BMessage *msg);

protected:
	BBitmap * GetPositinArrow(int32 newposition, int32 oldposion);

private:
	void LoadList(bool uselocal = true, const char *datname = NULL);
	status_t LoadSubjectFile(BFile *file);
	status_t LoadSubectFromINet(BFile *file);
	status_t MakeLocalList(BFile *file);
		
	void DoFind(BMessage *msg);
	void DoUpdate(BMessage *msg);
	void OpenBoard (BMessage *msg);
	void ListInvoked ();
	BRow* FindRowStringField(const char *label, int32 fieldNo);
	void SetColumns();
	void SetBitmaps();
		
	void ClearCache();
	void ClearAllCache();
	static status_t Run(void *_this);
	
	BDirectory *fCacheDir;
	BString fBoardUri;

	BBitmap *fBlueUpArrow; //(BRect(0, 0, kArrowWidth - 1, kArrowHeight - 1),  B_CMAP8);
	BBitmap *fYellowEqaulArrow;
	BBitmap *fRedDownArrow;
	BBitmap *fGrayBall;

	sem_id fStopSem;
	BFile *fDatFile;
	BString fOpenDatName;
	friend class aThread<ThreadListView>;
	ThreadRunner <ThreadListView> *fTreadRunner;
};

#endif //THREADLISTVIEW_H_INCLUDED

